package com.tools.ad.ui.crad.view;

import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;

import com.tools.ad.R;

/**
 * desc:
 * date: 2018/4/18
 * author: ancun
 */

public class AmBannerCardView extends LinearLayout {


    public AmBannerCardView(Context context) {
        super(context);
        initView(context);
    }

    public AmBannerCardView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public AmBannerCardView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    private void initView(Context context) {
        LayoutInflater layoutInflater = LayoutInflater.from(context);
        View view = layoutInflater.inflate(R.layout.ad_am_banner_card_layout, null);
        removeAllViews();
        ViewGroup.LayoutParams params = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        addView(view, params);
    }

    public void addAdView(View view) {
        RelativeLayout adContainer = findViewById(R.id.am_ad_container);
        adContainer.removeAllViews();
        adContainer.addView(view);
    }

}
